package co.edu.usbcali.egrapico.vista.ambient;

import co.edu.usbcali.egrapico.vista.tools.JPanelTranferHandlerRestriction;

public class PanelRestriction extends javax.swing.JInternalFrame implements java.io.Serializable {

    LPaneRestriction layeredPane;
    javax.swing.JScrollPane scroll1;
    private int suma = 0;
    private int resta = 0;
    private int mul = 0;
    private int div = 0;
    private int igual = 0;
    private int mayor_que = 0;
    private int mayor_igual_que = 0;
    private int menor_que = 0;
    private int menor_igual_que = 0;
    private int diferente_que = 0;
    private int valor = 0;
    private int variable = 0;
    private int argumento = 0;
    private int sender = 0;
    private boolean recepcion = false;
    private boolean esDeObjeto = false;

    /**
     * Creates a new instance of PanelDragAndDrop
     */
    public PanelRestriction(PanelRestriction ob) {
        this();
        recepcion = ob.isReception();
        esDeObjeto = ob.isOfObject();
        sender = ob.getSenderOperador();
        valor = ob.getValue();
        variable = ob.getVariable();
        argumento = ob.getArgumento();
        suma = ob.getSuma();
        resta = ob.getResta();
        mul = ob.getMul();
        div = ob.getDiv();
        igual = ob.getIgual();
        mayor_que = ob.getMayor();
        mayor_igual_que = ob.getMayorIgual();
        menor_que = ob.getMenor();
        menor_igual_que = ob.getMenorIgual();
        diferente_que = ob.getDiferente();
        layeredPane.setPreferredSize(ob.getLPane().getPreferredSize());
        layeredPane.setAreaLP(ob.getLPane().areaLPane());
        layeredPane.loadLPane(ob.getLPane());
        layeredPane.ApIcons(null);
    }

    public PanelRestriction() {
        super("",//+(++openFrameCount) 
                true, //resizable
                true, //closable
                true, //maximizable
                true);//iconifiable
        scroll1 = new javax.swing.JScrollPane();
        scroll1.setAutoscrolls(true);
        layeredPane = new LPaneRestriction();
        scroll1.setViewportView(layeredPane);
        getContentPane().add(scroll1);
        setDefaultCloseOperation(javax.swing.WindowConstants.HIDE_ON_CLOSE);
        setTransferHandler(new JPanelTranferHandlerRestriction());
        setSize(300, 300);
        //Set the window's location.
        setLocation(30, 30);
        setVisible(true);

    }

    public boolean isReception() {
        return recepcion;
    }

    public void setReception(boolean b) {
        recepcion = b;
    }

    public boolean isOfObject() {
        return esDeObjeto;
    }

    public void setIsOfObject(boolean b) {
        esDeObjeto = b;
    }

    public LPaneRestriction getLPane() {
        return layeredPane;
    }

    public void addMyListenerToLPane() {
        setTransferHandler(new JPanelTranferHandlerRestriction());
        layeredPane.addMyListener();
    }

    public void addLayeredPane(LabelIdeOpe label) {
        if (label.getName().equals("Add")) {
            label.setName(label.getName() + (++suma));
            label.setText(label.getName());
            label.setTextToolTip(label.getName() + ": ");
        } else if (label.getName().equals("Substract")) {
            label.setName(label.getName() + (++resta));
            label.setText(label.getName());
            label.setTextToolTip(label.getName() + ": ");
        } else if (label.getName().equals("Multiply")) {
            label.setName(label.getName() + (++mul));
            label.setText(label.getName());
            label.setTextToolTip(label.getName() + ": ");
        } else if (label.getName().equals("Divide")) {
            label.setName(label.getName() + (++div));
            label.setText(label.getName());
            label.setTextToolTip(label.getName() + ": ");
        } else if (label.getName().equals("Equal")) {
            label.setName(label.getName() + (++igual));
            label.setText(label.getName());
            label.setTextToolTip(label.getName() + ": ");
        } else if (label.getName().equals("Greater")) {
            label.setName(label.getName() + (++mayor_que));
            label.setText(label.getName());
            label.setTextToolTip(label.getName() + ": ");
        } else if (label.getName().equals("Greater Equal")) {
            label.setName(label.getName() + (++mayor_igual_que));
            label.setText(label.getName());
            label.setTextToolTip(label.getName() + ": ");
        } else if (label.getName().equals("Minor")) {
            label.setName(label.getName() + (++menor_que));
            label.setText(label.getName());
            label.setTextToolTip(label.getName() + ": ");
        } else if (label.getName().equals("Minor Equal")) {
            label.setName(label.getName() + (++menor_igual_que));
            label.setText(label.getName());
            label.setTextToolTip(label.getName() + ": ");
        } else if (label.getName().equals("Distinct")) {
            label.setName(label.getName() + (++diferente_que));
            label.setText(label.getName());
            label.setTextToolTip(label.getName() + ": ");
        } else if (label.getName().equals("Value")) {
            label.setName(label.getName() + (++valor));
            label.setText(label.getName());
            label.setTextToolTip(label.getName() + ": ");
        } else if (label.getName().equals("Variable")) {
            label.setName(label.getName() + (++variable));
            label.setText(label.getName());
            label.setTextToolTip(label.getName() + ": ");
        } else if (label.getName().equals("Argument")) {
            label.setName(label.getName() + (++argumento));
            label.setText(label.getName());
            label.setTextToolTip(label.getName() + ": ");
        } else if (label.getName().equals("Sender")) {
            label.setName(label.getName() + (++sender));
            label.setText(label.getName());
            label.setTextToolTip(label.getName() + ": ");
        }
        layeredPane.addLabel(label);
        layeredPane.addLabeltoVector(label);
        try {
            setSelected(true);
        } catch (java.beans.PropertyVetoException e) {
        }
    }

    public void setUndoLPane() {
        layeredPane.Undo();
        if (((LabelIdeOpe) layeredPane.getLastElementUndo()).getIcon().toString().endsWith("value.gif")) {
            valor--;
        }
    }

    public void setRedoLPane() {
        layeredPane.Redo();
    }

    public int getRedosize() {
        return layeredPane.getRedoSize();
    }

    public int getUndosize() {
        return layeredPane.getUndoSize();
    }

    public int getIdentificadores() {
        return valor + variable + argumento;
    }

    public void resSenderOperador() {
        sender--;
    }

    public void resValue() {
        valor--;
    }

    public void resVariable() {
        variable--;
    }

    public void resArgumento() {
        argumento--;
    }

    public void resSuma() {
        suma--;
    }

    public void resResta() {
        resta--;
    }

    public void resMul() {
        mul--;
    }

    public void resDiv() {
        div--;
    }

    public void resIgual() {
        igual--;
    }

    public void resMayor() {
        mayor_que--;
    }

    public void resMayorIgual() {
        mayor_igual_que--;
    }

    public void resMenor() {
        menor_que--;
    }

    public void resMenorIgual() {
        menor_igual_que--;
    }

    public void resDiferente() {
        diferente_que--;
    }

    public int getOperadoresMath() {
        return suma + resta + mul + div;
    }

    public int getOperadoresRel() {
        return igual + mayor_que + mayor_igual_que + menor_que + menor_igual_que + diferente_que;
    }

    public int getSenderOperador() {
        return sender;
    }

    public int getValue() {
        return valor;
    }

    public int getVariable() {
        return variable;
    }

    public int getArgumento() {
        return argumento;
    }

    public int getSuma() {
        return suma;
    }

    public int getResta() {
        return resta;
    }

    public int getMul() {
        return mul;
    }

    public int getDiv() {
        return div;
    }

    public int getIgual() {
        return igual;
    }

    public int getMayor() {
        return mayor_que;
    }

    public int getMayorIgual() {
        return mayor_igual_que;
    }

    public int getMenor() {
        return menor_que;
    }

    public int getMenorIgual() {
        return menor_igual_que;
    }

    public int getDiferente() {
        return diferente_que;
    }
}